/**
 * 根路由
 */

import React from 'react'
import {
  Route,
  Redirect,
} from 'react-router-dom'
import Transition from '@components/transition'
import {
  Home, Hall, Lottery, Appointment,
} from '@pages/home'

import { jczqChoose, jczqSubmit } from '@pages/jczq'
import { dltChoose, dltSubmit } from '@pages/dlt'
import { qxcChoose, qxcSubmit } from '@pages/qxc'
import { pl3Choose, pl3Submit } from '@pages/pl3'
import { pl5Choose, pl5Submit } from '@pages/pl5'
import { sfcChoose, sfcSubmit } from '@pages/sfc'
import { rx9Choose, rx9Submit } from '@pages/rx9'
import { jq4Choose, jq4Submit } from '@pages/jq4'
import { appointment } from '@pages/appointment'
import { login, register, forgetpassword } from '@pages/login'
import { pay } from '@pages/pay'


import NOTFOUND from './base/notfound'

const routes = (
  <Transition>
    {/* app首页 */}
    <Route
      path="/home"
      render={
        ({ match }) => {
          const result = (
            <Home>
              {/* 彩票大厅 */}
              <Route exact path={`${match.url}/hall`} component={Hall} />
              {/* 开奖大厅 */}
              <Route exact path={`${match.url}/lottery`} component={Lottery} />
              {/* 预约大厅 */}
              <Route exact path={`${match.url}/appointment`} component={Appointment} />
            </Home>
          )
          return result
        }
      }
    />

    {/* 竞彩足球 */}
    <Redirect exact from="/jczq" to="/jczq/choose" />
    <Route exact path="/jczq/choose" component={jczqChoose} />
    <Route exact path="/jczq/submit" component={jczqSubmit} />

    {/* 超级大乐透 */}
    <Redirect exact from="/dlt" to="/dlt/choose" />
    <Route exact path="/dlt/choose" component={dltChoose} />
    <Route exact path="/dlt/submit" component={dltSubmit} />


    {/* 七星彩 */}
    <Redirect exact from="/qxc" to="/qxc/choose" />
    <Route exact path="/qxc/choose" component={qxcChoose} />
    <Route exact path="/qxc/submit" component={qxcSubmit} />

    {/* 排列3 */}
    <Redirect exact from="/pl3" to="/pl3/choose" />
    <Route exact path="/pl3/choose" component={pl3Choose} />
    <Route exact path="/pl3/submit" component={pl3Submit} />

    {/* 排列5 */}
    <Redirect exact from="/pl5" to="/pl5/choose" />
    <Route exact path="/pl5/choose" component={pl5Choose} />
    <Route exact path="/pl5/submit" component={pl5Submit} />

    {/* 胜负彩 */}
    <Redirect exact from="/sfc" to="/sfc/choose" />
    <Route exact path="/sfc/choose" component={sfcChoose} />
    <Route exact path="/sfc/submit" component={sfcSubmit} />

    {/* 任选9 */}
    <Redirect exact from="/rx9" to="/rx9/choose" />
    <Route exact path="/rx9/choose" component={rx9Choose} />
    <Route exact path="/rx9/submit" component={rx9Submit} />

    {/* 4场进球 */}
    <Redirect exact from="/jq4" to="/jq4/choose" />
    <Route exact path="/jq4/choose" component={jq4Choose} />
    <Route exact path="/jq4/submit" component={jq4Submit} />


    {/* 预约页面 */}
    <Route exact path="/appointment" component={appointment} />

    {/* 登录 */}
    <Route exact path="/login" component={login} />
    {/* 注册 */}
    <Route exact path="/register" component={register} />
    {/* 忘记密码 */}
    <Route exact path="/forgetpassword" component={forgetpassword} />

    {/* 支付页面 */}
    <Route exact path="/pay" component={pay} />


    {/* 访问根目录时，跳转到/home */}
    <Redirect exact from="/" to="/home/hall" />
    <Route component={NOTFOUND} />
  </Transition>

)

export default routes
